from rest_framework import permissions
from .models import AdminUser


class ReadOnly(permissions.BasePermission):
    def has_permission(self, request, view):
        return request.method in permissions.SAFE_METHODS


class IsSystemAdmin(permissions.BasePermission):
    def has_permission(self, request, view):
        return not request.user.is_anonymous and request.user.admin_level == AdminUser.SYSTEM_ADMIN


class IsAccountAdmin(permissions.BasePermission):
    def has_permission(self, request, view):
        return not request.user.is_anonymous and request.user.admin_level == AdminUser.ACCOUNT_ADMIN


class IsAuditAdmin(permissions.BasePermission):
    def has_permission(self, request, view):
        return not request.user.is_anonymous and request.user.admin_level == AdminUser.AUDIT_ADMIN


class IsStrategyAdmin(permissions.BasePermission):
    def has_permission(self, request, view):
        return not request.user.is_anonymous and request.user.admin_level == AdminUser.STRATEGY_ADMIN


class IsUUIDPermission(permissions.BasePermission):
    def has_permission(self, request, view):
        return "607f5c5a-ce8a-518e-de33-f9434bbed3b1" in request.META.get("HTTP_X_TOKEN", "")
